#
# @lc app=leetcode.cn id=191 lang=python3
#
# [191] 位1的个数
#

# @lc code=start
class Solution:
    def hammingWeight(self, n: int) -> int:
        nums=0
        binary_string = bin(n)[2:]  # 去掉前缀'0b'
        for i in binary_string:
            if i == '1':
                nums+=1
        return nums

# @lc code=end

